package irio.gamer;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class GamerImage extends JPanel {

	private BufferedImage image = null;

	public String filename = "";

	int size = 500;

	public void loadImage() {
		try {
			image = ImageIO.read(new File(filename));
			// image.
		} catch (IOException ex) {
			// handle exception...
			image = null;
		}
		repaint();

	}

	public GamerImage(String file, String label) {
		filename = file;
		loadImage();
		JLabel lbl = new JLabel(label);
		lbl.setForeground(Color.gray);
		add(lbl);
	}

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		// setSize(getSize());
		if (image != null)
			g.drawImage(image, 0, 0, getWidth(), getHeight(), null); // see
																		// javadoc
																		// for
																		// more
																		// info
																		// on
																		// the
																		// parameters
		// g.drawImage(image,0, 0, size, size, null); // see javadoc for
		// more info on the parameters
	}

}